import {createRouter, createWebHistory} from 'vue-router'

import Layout from "@/views/Layout";
import Coures from "@/views/layout/Coures.vue";
import HomeWork from "@/views/layout/HomeWork.vue";
import CourseFile from "@/views/layout/CourseFile.vue";
import PersonInfo from "@/views/layout/PersonInfo.vue";
import Class from "@/views/layout/Class.vue";

const routes = [
    {
        path: '/login',
        name: 'Login',
        component: () => import("@/views/Login")
    },
    {
        path: '/404',
        name: '404',
        component: () => import("@/views/404.vue")
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import("@/views/Register")
    },
    {
        path: '/',
        name: 'Layout',
        component: Layout,
        redirect: '/login',//访问/会跳转到/home
        children: [
            {
                path: '/course',
                name: '课程',
                component: Coures
            },
            {
                path: '/homework',
                name: '作业',
                component: HomeWork
            },
            {
                path: '/files',
                name: '资源',
                component: CourseFile
            },
            {
                path: '/info',
                name: '个人信息',
                component: PersonInfo
            },
            {
                path: '/class',
                name: '加入班级',
                component: Class
            }
        ]
    },

]

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

export default router
